#!/usr/bin/perl 
# arguments.pl
use warnings;
use strict;

# list form takes mouse, cat, dog as arguments, fixed order.
animate('Jerry', 'Tom', 'Spike');

# hash form takes animals in any order using '-' prefix to identify type,   # also allows other animal types
animate(-Cat => 'Sylvester', -Bird => 'Tweety', -Mouse => 'Speedy Gonzales');

# and the subroutine...
sub animate {
   my %animals;

   # check first element of @_ for leading minus...
   if ($_[0]!~/^-/) {
      # it's a regular argument list, use fixed order
      @animals{'-Mouse', '-Cat', '-Dog'} = @_;
   } else {
      # it's named argument list, just assign it.
      %animals = @_;
   }
   # rest of subroutine...
   foreach (keys %animals) {
      print "$_ => $animals{$_} \n";
   }
}